#!/bin/bash

# This script is used to retrieve information about HMC
# Initially it will ony get the Serial Number, more can be added in later

JAVAPATH="/opt/IBMJava2-131/jre/bin/"
x=`type -p java 2>/dev/null`
if [ "$x" != "" ]
then
  JAVAPATH=`/usr/bin/dirname $x`
fi
getopt -Qn 'Error' hs

if [ "${DEBUG_JARS_DIRECTORY}" != "" ] ; then
  if [ -d ${DEBUG_JARS_DIRECTORY} ] ; then
    for i in ${DEBUG_JARS_DIRECTORY}/*.jar
    do
       debug_jars=${debug_jars}:$i
    done
  fi
fi

export CLASSPATH=${DEBUG_JARS_DIRECTORY}:${debug_jars}:/usr/websm/codebase/pluginjars/hsc.jar:/usr/websm/codebase/pluginjars/sniacimom.jar:/usr/websm/codebase/pluginjars/xerces.jar:/usr/websm/codebase/pluginjars/HwmcaCommon.jar:/usr/websm/codebase/pluginjars/auifw.jar:$CLASSPATH
export PATH=$JAVAPATH:$PATH

if [ $# -eq 0 ];
then echo
echo usage: getHMCInfo -s '     ' lists the serial number of the Console
echo
echo Options:
echo '   ' -h brings up this help screen
echo
exit 1
fi
if [ $1 = '--help' ];
then echo
echo usage: getHMCInfo -s '     ' lists the serial number of the Console
echo
echo Options:
echo '   ' -h brings up this help screen
echo
exit 0
fi

sn=`/opt/hsc/bin/hscdc x0 | grep "Serial No" | cut -f 2 -d ':' 2>/dev/null`
echo $sn
exit $?
